
<title>闸机出口</title>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">控制台</a>
    <a><cite>闸机出口</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-header">闸机出口</div>
    <div class="layui-card-body" style="padding: 15px;">
      <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item">
          <label class="layui-form-label">会员卡号</label>
          <div class="layui-input-block">
            <input type="text" name="cardNo" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
          </div>
        </div>

        
        <div class="layui-form-item">
          <div class="layui-input-block">
            <div class="layui-footer">
              <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'form', 'laydate'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,element = layui.element
  ,layer = layui.layer
  ,laydate = layui.laydate
  ,form = layui.form;
  
  form.render(null, 'component-form-group');

  laydate.render({
    elem: '#LAY-component-form-group-date'
  });
  
  /* 自定义验证规则 */
  form.verify({
    title: function(value){
      if(value.length < 5){
        return '标题至少得5个字符啊';
      }
    }
    ,pass: [/(.+){6,12}$/, '密码必须6到12位']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });
  
  /* 监听指定开关 */
  form.on('switch(component-form-switchTest)', function(data){
    layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
      offset: '6px'
    });
    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });
  
  /* 监听提交 */
  form.on('submit(component-form-demo1)', function(data){
    /* layer.alert(JSON.stringify(data.field), {
      title: '最终的提交信息'
    }) */
  //提交刷卡信息到数据库
    $.post(
    	"../consume",
    	data.field,
    	function(res){
    		if(res=="error"){
    			layer.alert('卡片异常，请联系管理员！')
    		}else{
    			layer.alert('欢迎下次光临！')
    		}
    	},'text'
    );
    return false;
  });
});
</script>